<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="employeeDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='employeeDetail.heading'/>"/>
    <meta name="menu" content="RoleAdminPurchase"/>

    <script type="text/javascript" src="<c:url value='/scripts/calendar/calendar.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/calendar/lang/calendar-es.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/calendar/calendar-setup.js'/>"></script>

    <script type="text/javascript">
        window.onload = function() {
            Calendar.setup({
                inputField: "entryDate",
                ifFormat: "%d/%m/%Y",
                button: "entryDate"
            });
        }
    </script>
</head>
<div id="help" >
    <h2>
        <a href="<c:url value='helpEmployeeForm.html?decorate=false'/>"
           title="<fmt:message key="help.pEF"/>"
           onclick="Modalbox.show(this.href, {title: this.title, width: 600}); return false;">
            <fmt:message key="help"/>
        </a>
    </h2>
</div>

<s:form id="employeeForm" action="saveEmployee" method="post" >
    <s:hidden id="employeeId" name="employee.id" value="%{employee.id}"/>
    <s:hidden key="employee.version"/>
    <s:hidden key="employee.username"/>
    <s:hidden key="employee.password"/>
    <s:hidden key="employee.confirmPassword"/>
    <s:hidden key="employee.passwordHint"/>
    <s:hidden name="employee.enabled" value="%{employee.enabled}"/>
    <s:hidden name="employee.accountExpired" value="%{employee.accountExpired}"/>
    <s:hidden name="employee.accountLocked" value="%{employee.accountLocked}"/>
    <s:hidden name="employee.credentialsExpired" value="%{employee.credentialsExpired}"/>

    <li>
        <div>
            <div class="left">
                <s:textfield key="employee.firstName" required="true" cssClass="text medium"/>
            </div>
            <div>
                <s:textfield key="employee.lastName" required="true" cssClass="text medium"/>
            </div>
            <div>
                <s:textfield key="employee.lastName2" cssClass="text medium"/>
            </div>
        </div>
    </li>

    <li>
        <div>
            <div class="left">
                <s:textfield key="employee.email" required="true" cssClass="text medium"/>
            </div>
            <div>
                <s:textfield key="employee.phoneNumber" cssClass="text medium"/>
            </div>
        </div>
    </li>

    <li>
        <label class="desc"><fmt:message key="employee.address.address"/></label>
        <div class="group">
            <div>
                <s:textfield key="employee.address.address" cssClass="text large" labelposition="bottom"/>
            </div>
            <div class="left">
                <s:textfield key="employee.address.city" required="true" cssClass="text medium"
                             labelposition="bottom"/>
            </div>
            <div>
                <s:textfield key="employee.address.province" required="true" cssClass="text state"
                             labelposition="bottom"/>
            </div>
            <div>
                <s:set name="country" value="employee.address.country" scope="page"/>
                <appfuse:country name="employee.address.country" prompt="" default="${country}"/>
                <p>
                    <label for="employee.address.country">
                        <fmt:message key="employee.address.country"/> <span class="req">*</span>
                    </label>
                </p>
            </div>
        </div>
    </li>
    <li>
        <fieldset>
            <legend><fmt:message key="employeeProfile.assignRoles"/></legend>
            <s:optiontransferselect list="roleListLeft" listKey="value" listValue="label"
                                    leftTitle="%{getText(employee.availableRoles)}"
                                    doubleList="roleListRight" doubleListKey="value" doubleListValue="label"
                                    rightTitle="%{getText(employee.roles)}"
                                    doubleName="selectRoles" />
        </fieldset>
    </li>

    <s:textfield key="employee.task" required="true" cssClass="text medium"/>
    <s:textfield key="employee.salarieFixed" cssClass="text medium"/>
    <s:textfield id="entryDate" key="employee.entryDate" required="true" readonly="true" cssClass="text medium"/>

    <li class="buttonBar bottom">
        <s:submit cssClass="button" method="save" key="button.save" theme="simple"/>
        <c:if test="${not empty employee.id}">
            <s:submit cssClass="button" method="delete" key="button.delete" onclick="return confirmDelete('employee')" theme="simple"/>
        </c:if>
        <s:submit cssClass="button" method="cancel" key="button.cancel" theme="simple"/>
    </li>
</s:form>

<script type="text/javascript">
    Form.focusFirstElement($("employeeForm"));
</script>